from flask import Flask
from flask import request
from queue import Queue
import json

app = Flask(__name__)

Test = "hello world"

q=Queue()

@app.post("/add_letter")
def add():
    name = request.form['name']
    content = request.form['content']
    q.put((name, content))
    return "ok"

@app.route("/pop_letter")
def pop():
    body = ""
    if q.empty() == True:
        return "null"
    else:
        (name, content) = q.get()
        body = {
                "userName": name
                , "content": content
            }
        return json.dumps(body)

app.run(host="0.0.0.0", port=8081)
